<?php
/* SVN FILE: $Id: league.php 250 2010-06-17 10:55:41Z gregory.rome $ */
/**
 * League Model.
 *
 * @todo Add file description.
 *
 * cBBweb : Digital Blood Bowl league interface (http://code.google.com/p/cbbweb/)
 * Copyright 2009-2010, Grégory Romé.
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2009-2010, Grégory Romé.
 * @link          http://code.google.com/p/cbbweb/ cBBweb Project
 * @package       cbbweb
 * @subpackage    cbbweb.models
 * @version       $Revision: 250 $
 * @modifiedby    $LastChangedBy: gregory.rome $
 * @lastmodified  $Date: 2010-06-17 10:55:41 +0000 (Thu, 17 Jun 2010) $
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * League Model.
 *
 * @todo Add class description.
 *
 * @package       cbbweb
 * @subpackage    cbbweb.models
 */
class League extends AppModel {

	var $name = 'League';

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
		'Coach' => array(
			'className' => 'Coach',
			'foreignKey' => 'coach_id',
			'conditions' => '',
			'fields' => array('Coach.id','Coach.strName'),
			'order' => ''
		)
	);

	var $hasMany = array(
		'Championship' => array(
			'className' => 'Championship',
			'foreignKey' => 'league_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Team' => array(
			'className' => 'Team',
			'foreignKey' => false,
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => 'SELECT Team.`id`, Team.`strName`, Team.`race_id`, Team.`coach_id`, Team.`iValue`, Coach.strName, Race.DATA_CONSTANT FROM teams Team JOIN races As Race ON (Race.id = Team.race_id) JOIN coaches As Coach ON (Coach.id = Team.coach_id) JOIN team_statistics As TeamStatistic ON (Team.id = TeamStatistic.team_id) JOIN divisions As Division ON (Division.id = TeamStatistic.division_id) JOIN championships As Championship ON (Championship.id = Division.championship_id) WHERE Championship.league_id = {$__cakeID__$}',
			'counterQuery' => ''
		)
	);

	var $hasAndBelongsToMany = array('Coach');

}
?>